<template>
  <page-header-wrapper>
    <a-card :bordered="false">
      <div class="gtitle" style="margin-bottom: 20px"><a-icon type="info-circle" style="color: #108ee9" theme="filled"/>密码安全策略设置</div>

      <div class="rowtxt">
        <a-row class='rowmb'>
          <a-col :span="24">密码安全策略只针对新建用户、修改密码时有效。</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">最小字符数:</a-col>
          <a-col :span="4"><a-input-number style="width: 100%" placeholder=""  v-model="config.minCharacterNum" @blur="updateconfig('minCharacterNum',config.minCharacterNum)"></a-input-number></a-col>
          <a-col :span="16" :offset="1">0表示不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">最大字符数:</a-col>
          <a-col :span="4"><a-input-number style="width: 100%" placeholder="" v-model="config.maxCharacterNum" @blur="updateconfig('maxCharacterNum',config.maxCharacterNum)"></a-input-number></a-col>
          <a-col :span="16" :offset="1">0表示不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">必须包含的字符类型:</a-col>
          <a-col :span="18">
            <a-checkbox-group v-model="config.mustIncludCharacterType"  @change="updateconfig('mustIncludCharacterType',config.mustIncludCharacterType)">
              <span class="rowspan">
                 <a-checkbox value="大写字母">大写字母</a-checkbox>
              </span>
              <span class="rowspan">
                 <a-checkbox value="小写字母">小写字母</a-checkbox>
              </span>
              <span class="rowspan">
                 <a-checkbox value="数字">数字</a-checkbox>
              </span>
              <span class="rowspan">
                 <a-checkbox value="特殊字符">特殊字符</a-checkbox>
              </span>
            </a-checkbox-group>
          </a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">最小存留期:</a-col>
          <a-col :span="4"><a-input-number style="width: 100%" placeholder="" v-model="config.minRetentionNum" @blur="updateconfig('minRetentionNum',config.minRetentionNum)"></a-input-number></a-col>
          <a-col :span="16" :offset="1">连续修改密码的时间间隔，0表示不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">最大存留期:</a-col>
          <a-col :span="4"><a-input-number style="width: 100%" placeholder="" v-model="config.maxRetentionNum" @blur="updateconfig('maxRetentionNum',config.maxRetentionNum)"></a-input-number></a-col>
          <a-col :span="16" :offset="1">密码的最长有效期，0表示不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">密码到期提醒时间:</a-col>
          <a-col :span="3"><a-input-number style="width: 100%" placeholder="" v-model="config.passwordExpirationReminderTime" @blur="updateconfig('passwordExpirationReminderTime',config.passwordExpirationReminderTime)"></a-input-number></a-col>
          <a-col :span="1">天</a-col>
          <a-col :span="16" :offset="1">设置密码最大存留期后，到期前的提醒时间，0表示不提醒</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">首次登录是否修改密码:</a-col>
          <a-col :span="4">
            <a-radio-group v-model="config.firstLoginUpdatedPwd" @change="updateconfig('firstLoginUpdatedPwd',config.firstLoginUpdatedPwd)">
              <span class="rowspan" style="width: 50%">
                 <a-radio :value="1">是</a-radio>
              </span>
              <span class="rowspan" style="width: 50%">
                 <a-radio :value="0">否</a-radio>
              </span>

            </a-radio-group>
          </a-col>
          <a-col :span="16" :offset="1">开启后，新建用户或用户初始化密码后，必须先修改初始密码才能进入系统</a-col>
        </a-row>
      </div>

      <div class="gtitle" style="margin-bottom: 20px;margin-top: 20px"><a-icon type="info-circle" style="color: #108ee9" theme="filled"/>系统备份管理与还原</div>
      

      <div class="rowtxt">
        <a-row class='rowmb'>
          <a-col :span="3">错误登录后开启验证:</a-col>
          <a-col :span="4">
            <a-radio-group  v-model="config.errorLoginTips" @change="updateconfig('errorLoginTips',config.errorLoginTips)">
              <span class="rowspan" style="width: 50%">
                 <a-radio :value="1">是</a-radio>
              </span>
              <span class="rowspan" style="width: 50%">
                 <a-radio :value="0">否</a-radio>
              </span>
            </a-radio-group>
          </a-col>
          <a-col :span="16" :offset="1">开启后，任意用户错误登录后，将自动开启图形化验证码进行校验</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">最大错误登录次数:</a-col>
          <a-col :span="4"><a-input-number style="width: 100%" placeholder="" v-model="config.maxErrorLoginNum" @blur="updateconfig('maxErrorLoginNum',config.maxErrorLoginNum)"></a-input-number></a-col>
          <a-col :span="16" :offset="1">连续登录超过该次数后，系统将锁定该用户，0表示不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">错误锁定时间:</a-col>
          <a-col :span="3"><a-input-number style="width: 100%" placeholder="" v-model="config.errorLockTime" @blur="updateconfig('errorLockTime',config.errorLockTime)"></a-input-number></a-col>
          <a-col :span="1">分钟</a-col>
          <a-col :span="16" :offset="1">冻结超过错误次数的用户登录时间，0表示不不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">最长空闲会话时间:</a-col>
          <a-col :span="3"><a-input-number style="width: 100%" placeholder=""  v-model="config.maxSessionTime" @blur="updateconfig('maxSessionTime',config.maxSessionTime)"></a-input-number></a-col>
          <a-col :span="1">分钟</a-col>
          <a-col :span="16" :offset="1">用户无任何操作超过所填时间后，将自动注销，0表示不不限</a-col>
        </a-row>
        <a-row class='rowmb'>
          <a-col :span="3">开启用户多登录:</a-col>
          <a-col :span="4">
            <a-radio-group v-model="config.enableMultiUserLogin" @change="updateconfig('enableMultiUserLogin',config.enableMultiUserLogin)">
              <span class="rowspan" style="width: 50%">
                 <a-radio :value="1">是</a-radio>
              </span>
              <span class="rowspan" style="width: 50%">
                 <a-radio :value="0">否</a-radio>
              </span>
            </a-radio-group>
          </a-col>
          <a-col :span="16" :offset="1">默认每用户仅能在一处进行登录，开启后支持用户多处登录</a-col>
        </a-row>
      </div>

    </a-card>
  </page-header-wrapper>
</template>

<script>
  import { getsafeconfig,updatesafeconfig } from '@/api/safe'
  import {} from '../../utils/constant'
  export default {
    name: 'PatchUpdateManage',
    data() {
      return {
        wordtype:[],
        config:{}
      }
    },
    mounted() {
      this.$info(
        {
          title:'提示',
          content:'测试Lisence未授权！',
          onOk:()=> {
            this.$router.push({ path: '/overview/overview' })
          },
        }
      )
      this.getsafeconfig()
    },
    methods:{
      getsafeconfig(){
        getsafeconfig({id:1}).then(res=>{
          if(res.data.mustIncludCharacterType){
            res.data.mustIncludCharacterType = res.data.mustIncludCharacterType.split(',')
          }
          this.config = res.data
        })
      },
      updateconfig(key,value){
        let json = {}
        json.id = 1
        if(key == 'mustIncludCharacterType'){
          value = value.join(',')
        }
        json[key] = value
        updatesafeconfig(json).then(res=>{})
      },

    }
  }
</script>

<style lang="less"  scoped>

  .gtitle{
    background-color: #e6f3fc;
    line-height: 40px;
    padding-left: 20px;
    color: #333;
    font-weight: bold;

    i{
      margin-right: 10px;
    }
  }
  .rowtxt,.ant-radio-group{
    line-height: 32px;

  }
  .ant-radio-group{
    width: 100%;
  }
  .rowspan{
    display: inline-block;
    width: 150px;
  }
  .showtxt{
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0 10px;
    height: 120px;
    overflow-y: auto;
  }
  .rowmb{
    margin-bottom: 10px;
  }
  .blue{
    color: #3366FF;
  }
  .iplist{
    border: 1px solid #ddd;
    padding: 5px;
    min-height: 100px;
    line-height: 30px;
    div:hover{
      background-color: #efefef;
    }
    .icon{
      color: red;
      cursor: pointer;
      line-height: 30px;
      float: right;
      margin-right: 20px;
    }
  }

</style>
